<script setup>
import { useRouter } from 'vue-router';
import "../assets/date"
import axios from "axios"
import { onMounted, ref } from "vue"
let aa = ref("")
let router = useRouter()
onMounted(() => {
    axios.get("api/sp").then(res => {
        aa.value = res.data.data
    })
})
</script>
<template>
    <div class="box">
        <div class="title">
            校园易购
        </div>
        <div class="left" v-for="item in aa">
            <img :src="item.img" alt="" class="tu">
            <div class="xiaof">
                <div class="xiaozi">
                    <span>{{ item.name }}</span>
                    <div class="wen">
                        <span>￥:{{ item.jiage }}</span>
                        <span>原价:{{ item.yj }}</span>
                    </div>
                </div>
                <span class="sc">{{ item.sc }}</span>
            </div>
            <div class="top">
                <span>100g</span>
                <span>200g</span>
                <span>400g</span>
            </div>
            <div class="gwc">
                <span>加入购物车</span>
            </div>
        </div>
        <div class="right">
            <div class="wen1">推荐搭配</div>
            <el-scrollbar class="ccc">
                <div class="scrollbar-flex-content">
                    <p v-for="item in 3" :key="item" class="scrollbar-demo-item">

                        {{ item }}
                    </p>
                </div>
            </el-scrollbar>
        </div>
        <div class="wen2">
            <div class="zizi">详情</div>
            <div class="zi">
                <span>品牌：双汇</span>
                <span>生产日期:2023-11-1</span>
                <span>保质期:2023-12-30</span>
            </div>
        </div>
        <el-col class="yc">
            <RouterLink to="/" class="wz">首页</RouterLink>
            <RouterLink to="/gouwuche" class="wz">购物车</RouterLink>
            <RouterLink to="/Home" class="wz">我的</RouterLink>
        </el-col>
    </div>
</template>
<style scoped>
.box {
    width: 375px;
    margin: 0 auto;
    border: 1px solid #ccc;
}

.title {
    height: 25px;
    font-size: 25px;
    font-weight: bold;
    text-align: center;
    line-height: 20px;
}

.right {
    padding: 20px;
    width: 100%;
    background-color: #f7f5f5;
}

.wen2 {
    width: 100%;
    padding: 20px;
}

.zizi {
    padding: 10px;
    color: black;
    font-size: 18px;
}
.zi{
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.wen1 {
    padding: 10px;
}

.gwc {
    width: 150px;
    height: 40px;
    color: white;
    background-color: blue;
    border-radius: 999px;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.top {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    padding: 20px;
}

.top span {
    width: 80px;
    height: 40px;
    border: 1px solid #ccc;
    text-align: center;
    padding-top: 7px;
}

.left {
    width: 100%;
    padding: 20px;
}

.tu {
    width: 100%;
    height: 200px;
}

.xiaof {
    display: flex;
    justify-content: space-around;
}

.xiaozi {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wen {
    display: flex;
    gap: 10px;
}

.wen span:nth-of-type(1) {
    font-size: 18px;
    color: red;
}

.wen span:nth-of-type(2) {
    color: #ccc;
    font-size: 14px;
}

.sc {
    border-radius: 999px;
    width: 40px;
    height: 40px;
    border: 1px solid #ccc;
    padding-top: 7px;
    text-align: center;
    font-weight: bold;
}

.scrollbar-flex-content {
    background-color: #eeeded;
    display: flex;
}

.scrollbar-demo-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 200px;
    margin: 10px;
    text-align: center;
    border-radius: 4px;
    background: var(--el-color-danger-light-9);
    color: var(--el-color-danger);
}

.yc {
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 20px;
    border: 1px solid #ccc;
}

.wz {
    color: black;
    text-align: center;
    text-decoration: none;
}</style>